package PTA;

import java.util.Scanner;

public class PTA_7_55 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        char[] str = S.toCharArray();
        int flag = 0;
        for (int i = 0; i < str.length; i++) {
            if((i == 0) && Character.isLetter(str[i])) {
                if(!Character.isLowerCase(str[i])) {
                    flag++;
                }
            }
            if(i>=1&&1<=3) {
                if(Character.isLowerCase(str[i])) {
                    flag++;
                }
            }
            if(i>3) {
                if(Character.isDigit(str[i])) {
                    flag++;
                }
            }
        }
        if(flag == 7) {
            System.out.println(S + "合法");
        }
        else {
            System.out.println(S + "不合法");
        }

    }
}
